package top.superflow.verify

import org.apache.commons.lang3.StringUtils
import top.superflow.exception.{EmptyArgumentException, NullArgumentException, RequestUnsupportedException}

trait Ensure {
  
  def notEmpty(target : String, message : String){
    if(StringUtils.isEmpty(target)) throw new EmptyArgumentException(message);
  }
  
  def notNull(target : Any, message : String = null){
    var finalMessage = message
    if(finalMessage == null){
      finalMessage = "The argument should not be null."
    }
    if(target == null) throw new NullArgumentException(finalMessage);
  }
  
  def notSupported (target : Any){
    throw new RequestUnsupportedException(target)
  }
}